using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.Drawing;

namespace Common.Shared.Xml.Serialization {
  internal static class ObjectSerializerHelper {
    public static string SerializeObject ( object obj ) {
      if ( obj.GetType() == typeof ( Color ) )
        return SerializeColor ((Color) obj ).ToString ( );
      else
        return obj.ToString ( );
    }

    public static object DeserializeObject ( Type t, string val ) {
      if ( t == typeof ( Color ) )
        return DeserializeColor ( int.Parse ( val ) );
      else {
        return null;
      }
    }

    private static int SerializeColor( Color color ) {
      return color.ToArgb ( );
    }

    private static Color DeserializeColor ( int argb ) {
      return Color.FromArgb ( argb );
    }
  }
}
